package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.AccountEmployee;
import com.briup.jz.bean.extend.AccountEmployeeExtend;
import com.briup.jz.service.IAccountEmployeeService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/employee")
@Api(description = "员工账户管理接口")
public class AccountEmployeeController {
    @Autowired
    private IAccountEmployeeService accountEmployeeService;

    @ApiOperation("查询所有员工操作")
    @GetMapping("query")
    public Message query(Double transfer_money, String type, String status, Long userId) {
        List<AccountEmployee> list = accountEmployeeService.query(transfer_money, type, status, userId);
        return MessageUtil.success(list);

    }
    @ApiOperation("级联查询所有员工操作")
    @GetMapping("queryCascade")
    public Message queryCascade(Double transfer_money, String type, String status, Long userId) {
        List<AccountEmployeeExtend> list = accountEmployeeService.queryCascade(transfer_money, type, status, userId);
        return MessageUtil.success(list);

    }
    @ApiOperation("保存或更新员工信息")
    @PostMapping ("saveOrUpdate")
    public Message saveOrUpdate(AccountEmployee accountEmployee) throws Exception {
        accountEmployeeService.saveOrUpdate(accountEmployee);
        return MessageUtil.success("更新成功");
    }

    @ApiOperation(value = "通过id删除员工信息")
    @GetMapping("deleteById")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
    })
    public Message deleteById(@NotNull Long id){
        accountEmployeeService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
}
